

#include <iostream>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long lld;

lld MOD = 998244353;

const int N = 1e6 + 10;

lld fastmi(lld a, lld n) {
	lld ans = 1;

	while (n) {
		if (n & 1)ans = ans * a % MOD;

		a *= a;
		a %= MOD;
		n >>= 1;
	}

	return ans;
}

lld inv[N];

void initInv() {
	lld sum = 1;
	inv[0] = 1;
	for (lld i = 1; i < N; ++i) {
		sum *= i;
		sum %= MOD;
		inv[i] = fastmi(sum, MOD - 2);
		// if (i < 10)cout <<sum<<", "<< inv[i] << ", " << (inv[i]*sum%MOD) << endl;
	}
}

int lowbit(int x) {
	return x & (-x);
}

lld arr[N];

lld C[1010][1010];

void initC() {
	C[0][0] = 1;
	C[1][0] = C[1][1] = 1;

	for (int i = 2; i < 1010; i++) {
		C[i][0] = C[i][i] = 1;
		for (int j = 1; j < i; ++j) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}
}



void solve() {
	initInv();
	initC();
	int t;
	cin >> t;
	while (t--) {
		lld n, k;
		cin >> n >> k;
		for (int i = 1; i <= n; ++i)cin >> arr[i];

		for (int i = 1; i <= n; ++i) {
			lld isum = 1;
			for (int j = i + lowbit(i), d = 1; j <= n; j += lowbit(j), d++) {
				isum = isum * ((k - 1 + d) % MOD) % MOD;
				//cout << j<<", "<< d<<", "<< isum * inv[d] % MOD<<endl;
				arr[j] -= isum * arr[i] % MOD * inv[d] % MOD;
				arr[j] %= MOD;
				//cout << "mat" << k - 1 << ", " << d << endl;
				//cout << "C" << k - 1 +d<< ", " << d<< "=" << isum * inv[d] % MOD<< endl;
				/*arr[j] -= C[k-1+d][d] * arr[i] % MOD;
				arr[j] %= MOD;*/

				//cout << "C" << k - 1 + d << ", " << d << "=" << C[k - 1 + d][d] << endl;
			}
		}

		for (int i = 1; i <= n; ++i) {
			if (arr[i] < 0)arr[i] += MOD;
			cout << arr[i] << " ";
		}

		cout << endl;
	}
}


int main() {
	solve();
	return 0;
}
/*
2
8 100
1 2 1 4 1 2 1 8
6 7
1 4 3 17 5 16

2
8 1
1 2 1 4 1 2 1 8
6 2
1 4 3 17 5 16

 */


lld CC(lld n, lld m) {
	lld sum = 1;
	for (int i = n; i > (n - m); --i) sum = sum * i % MOD;
	return sum * inv[m] % MOD;
}